<?php

include_once 'inc/global.php';

//if (strlen(session_id()) < 1)
//    session_start();

//if (!isset($_SESSION['tid']))
//    $_SESSION['tid'] = '';

$tid = $_GET['t'];// $_SESSION['tid'];
$tablename = $tables[$tid]['t'];

$id = intval($_REQUEST['id']);

include 'inc/conn.php';

$sql = "delete from $tablename where id=$id";

$result = @mysql_query($sql);

if ($tid == 3) {
    //delete package, delete images also
    $sql = "delete from ats_package_images where packageid='$id'";
    mysql_query($sql);
    
    //delete itinerary
    $sql = "delete from ats_itinerary where packageid='$id'";
    mysql_query($sql);
    
    //delete package prices
    $sql = "delete from ats_packageprices where packageid='$id'";
    mysql_query($sql);
    
    //delete visaprices
    $sql = "delete from ats_visaprices where packageid='$id'";
    mysql_query($sql);
}

if ($result) {
    echo json_encode(array('success' => true));
} else {
    echo json_encode(array('msg' => 'Some errors occured.'));
}
?>